package com.gzgs.dao;

import com.gzgs.domain.Permission;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId=#{id})")
    List<Permission> findPermissionByRoleId(String id)throws Exception;

    @Select("select * from permission")
    List<Permission> findAll()throws Exception;

    @Insert("insert into permission(permissionName,url)values(#{permissionName},#{url})")
    void savePermission(Permission permission) throws Exception;

    @Select("select * from permission where id=#{id}")
    Permission findById(String id) throws Exception;


    @Delete("delete from role_permission where permissionId=#{id}")
    void deletePermissionFromRole_permission(String id);

    @Delete("delete from permission where id=#{id}")
    void deletePermissionById(String id);

}
